import pagination from '@/views/pagination'  //分页组件 
import dialogForm from './edit'
import agentHttp from '@/utils/agentHttp.js'
import {debounce,setEndDateTime} from '@/utils/index.js'
export default {
  components:{dialogForm,pagination},
  name: 'finalTrial',
  created(){
    this.getOrderList();
  },
  data() {
  	return {
      //表格字段
      tableData: [{
      }],
      searchForm:{
        startDate:"",
        endDate:"",
        logisticsStatus:'',
        inspectionStatus:'',
        depositStatus:''
      },
      //弹窗状态数据
      dialogSendData:{
        isAdd:"",
        dialogFormVisible:"",
        id:""
      },
      formLabelWidth:'120px',
      logisticsInfoStatusMap:'',
      carInspectionInfoStatusMap:'',
      cashDepositInfoStatusMap:'',     
      startDateOpt: {
        disabledDate(time) {
          return time.getTime() > Date.now() 
        }
      },
      endDateOpt:{
        disabledDate:(time)=>{
          return  time.getTime()< new Date(this.searchForm.startDate).getTime();
        }
      },
      resetFormStatus:false        
  	}
  },
  methods: {
    //延迟搜索
    debounceSeach(){
      this.tableData.page=1;
      debounce(this.getOrderList(),1000)
    },
    //重置
    resetSearchForm(formName) {
        this.resetFormStatus=true;
        this.tableData.page=1;
        this.tableData.rows=10;
        this.$refs[formName].resetFields();
        this.$nextTick(_ =>{
          this.resetFormStatus=false;
          this.getOrderList();
        })
    },
    handleEdit(index, row){
      this.dialogSendData.isAdd=true;
      this.dialogSendData.id = row.id;
      this.dialogSendData.dialogFormVisible=true;
    },
    handleSee(index, row){
      this.dialogSendData.isAdd=false;
      this.dialogSendData.id = row.id;
      this.dialogSendData.dialogFormVisible=true;
    }, 
    //终审数据列表
    getOrderList(){
      if(!this.resetFormStatus){
        var params=this.searchForm||{};
        params.page=this.tableData.page||1;
        params.rows=this.tableData.rows||10;
        params.endDate = setEndDateTime(params.endDate);
        agentHttp.postJson('adminApi/admin/car_order/list_final_review?page='+params.page+'&rows='+params.rows,params).then((data)=>{
          if (data.success) {
            this.logisticsInfoStatusMap = data.data.logisticsInfoStatusMap;
            this.carInspectionInfoStatusMap = data.data.carInspectionInfoStatusMap;
            this.cashDepositInfoStatusMap = data.data.cashDepositInfoStatusMap;
            this.tableData = data.data.tableData; 
          }
        })      
      }     
    }
  }
}
